import type { RouteRecordRaw } from "vue-router";
import { createRouter, createWebHistory } from "vue-router";
import NProgress from "nprogress";
// 导出配置routes
import { routesdata } from "~/router/router";

const routes: RouteRecordRaw[] = routesdata;

const router = createRouter({
  history: createWebHistory(),
  routes,
});

router.beforeEach(() => {
  if (!NProgress.isStarted()) {
    NProgress.start();
  }
});

router.afterEach(() => {
  NProgress.done();
});

export default router;
